Skip to content

added a conversion function from uri to iceorxy2 addressing scheme #71

Merged
sophokles73 merged 15 commits into
eclipse-uprotocol:mainfrom
catappreciationhours2:conversion
Jul 25, 2025
Merged

added a conversion function from uri to iceorxy2 addressing scheme #71
sophokles73 merged 15 commits into
eclipse-uprotocol:mainfrom
catappreciationhours2:conversion

Conversation

@catappreciationhours2
Copy link
Copy Markdown
Contributor

Helper methods:

  • compute_service_name to compute correct Iceoryx2 service names from UMessage
  • encode_uuri_segments and encode_hex_no_leading_zeros to format UUri segments

Unit tests covering service name computation for:

  • publish
  • notification
  • RPC request
  • RPC response

missing URIs (return proper UCode::INVALID_ARGUMENT)

This sets up the foundation for integrating uProtocol transport over Iceoryx2.

Closes #66

@PLeVasseur
Copy link
Copy Markdown
Contributor

@catappreciationhours2 -- thanks for opening this!

Closes #66

Reading through this quickly, I think this should be:

Closes #14, #15

Since in this PR you've got implementation and testing of the UUri => ServiceName. I didn't spot implementation of handling of the payload. Let me know if I missed something ☺️

Copy link
Copy Markdown
Contributor

@PLeVasseur PLeVasseur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @catappreciationhours2 -- thanks for putting up this PR. ☺️

I've left some suggestions. Could you take a look?

If possible I'd like us to have one go-round with you and the other students attempting to make changes / post comments here before we meet up on Monday. Seem doable?

Comment thread .github/workflows/check.yml Outdated
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
}

fn compute_service_name(message: &UMessage) -> Result<String, UStatus> {
let join_segments = |segments: Vec<String>| segments.join("/");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat approach. Think this is probably fine.

Was wondering if you'd considered using a function defined local to this function vs using a closure like this. Wondered on if there are any trade-offs between the two. I don't know of any off-hand and it might be useful for your learning.

Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread .github/workflows/check.yml Outdated
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Copy link
Copy Markdown
Contributor

@sophokles73 sophokles73 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also make sure to format your code properly using

cargo fmt -all

or (better) configure VSCode to automatically format your code when saving a file.

Comment thread src/lib.rs Outdated
@sophokles73
Copy link
Copy Markdown
Contributor

@catappreciationhours2 please make sure to use the email address in your commits that you have used to register your Eclipse Foundation account and that you have signed the Eclipse Contributor Agreement (ECA) for.

Otherwise, the eclipsefdn/eca check will always fail and we cannot merge your PR(s).

@vidishac2004
Copy link
Copy Markdown
Contributor

All the changes have been incorporated in the most latest commit by @catappreciationhours2 . Just a few questions about our implementation of compute service names:

  1. Is using the type a good idea for the sink UURI's since publish messages don't necessary have one?
  2. In the serviceName RESPONSE example- 403AB is truncated to 3AB, do we need to carry out truncation? Becuase from the examples provided to us in the spec, the ue_type is 403AB, but if i enter that in the test, it shows overflow, so do we have to alter our code for those cases?
  3. Do we need to check for the fact that if publish sink is provided, it must be equal to the authority name?
Screenshot 2025-07-15 at 9 32 38 PM

Copy link
Copy Markdown
Contributor

@PLeVasseur PLeVasseur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @catappreciationhours2 -- thanks for the adjustments!

I left a few more comments. In general I think making use of the provided helper functions on UUri as @sophokles73 pointed out can help with readability of the code.

Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
@PLeVasseur
Copy link
Copy Markdown
Contributor

Hey @vidishac2004, let's tackle these questions:

  1. Is using the type a good idea for the sink UURI's since publish messages don't necessary have one?

I'm not sure I understand the question here. A Publish message doesn't have to have a sink UUri, it's true. We can check for presence or absence of the sink UUri to give us a hint on if it is not or is a Publish message.

If there's a sink UUri we can then check that the authority is the "host" authority.

  1. In the serviceName RESPONSE example- 403AB is truncated to 3AB, do we need to carry out truncation? Becuase from the examples provided to us in the spec, the ue_type is 403AB, but if i enter that in the test, it shows overflow, so do we have to alter our code for those cases?

So taking these source and sink UUris:

Item Result
Source URI up://device1/CD/4/B
Sink URI up://device1/403AB/3/0
iceoryx2 ServiceName up/device1/CD/0/4/B/device1/3AB/4/3/0

I tried to explain how we end up with the ServiceName that we do:

ue_id-to-type_id-and-instance_id

I did this breakdown from ue_id to service_id and instance_id based on the uEntity definition given in the spec.

  1. Do we need to check for the fact that if publish sink is provided, it must be equal to the authority name?

Yes, that seems reasonable. If a sink UUri is provided the authority must be equal to the "host" authority we can configure when making the Iceoryx2Transport.

@PLeVasseur
Copy link
Copy Markdown
Contributor

Amending my earlier comment a bit:

If there's a sink UUri we can then check that the authority is the "host" authority.

Yes, that seems reasonable. If a sink UUri is provided the authority must be equal to the "host" authority we can configure when making the Iceoryx2Transport.

The situation here is a little more involved. I'll write something up about this. For now, I think we should check that if there is a sink UUri, that the sink UUri has only the authority_name field set.

I need to educate myself a little more on e.g. why the LocalUriProvider trait is no longer implemented in up-transport-zenoh-rust. I think I'm out of the loop.

@PLeVasseur
Copy link
Copy Markdown
Contributor

Additionally, I'm a little unclear on the Publish section of the UAttributes spec portion where it says that the sink UUri

MAY be present in the message. If present, the UUri MUST only contain the authority_name field.

As far as I know in Protobuf the way we've defined UUri the other fields would still be present. Can you help sanity check me here @sophokles73?

@sophokles73
Copy link
Copy Markdown
Contributor

If a sink UUri is provided the authority must be equal to the "host" authority we can configure when making the Iceoryx2Transport.

No, the reason for allowing an authority name in the sink of Publish messages was to support the streamer use case so that the streamer can (canonically) route messages to outbound transports, in particular to an off-vehicle message broker when using the MQTT5 transport for connecting the vehicle to a cloud backend.

IIRC the idea was, that the streamer would use information from its local uSubscription service to determine if the back end is interested in events produced locally in the vehicle and then add a sink URI containing the backend's authority name into such Publish messages before routing the message to the outbound transport. The MQTT5 transport would then use this information to create the topic name that the MQTT5 spec prescribes for off-vehicle communication.

Copy link
Copy Markdown
Contributor

@PLeVasseur PLeVasseur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @catappreciationhours2 -- thanks for the revision. I've taken a look and offered up some suggestions. Can you take a peek?

Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs
assert_eq!(name, "up/device1/CD/0/4/B/device1/3AB/4/3/0");
}

// performing failing tests for service name computation
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look reasonable. Would encourage you to think more about all the ways compute_service_name() can fail and try to cover those various branches.

If you've already covered -- great! If not, would be good to add those too.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this open to see if you've given thought and covered all the possible branches.

Copy link
Copy Markdown
Contributor

@PLeVasseur PLeVasseur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @vidishac2004 -- nearing completion! I left a few comments and the build is failing.

Comment thread .gitignore Outdated
Comment thread .github/workflows/check.yml Outdated
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs
Comment thread src/lib.rs Outdated
Comment thread src/lib.rs
assert_eq!(name, "up/device1/CD/0/4/B/device1/3AB/4/3/0");
}

// performing failing tests for service name computation
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this open to see if you've given thought and covered all the possible branches.

Comment thread src/lib.rs
let src_id = source.resource_id;
let sink_id = sink.map(|s| s.resource_id);

if src_id == 0 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could have kept the match, but refactored a bit to avoid the .contains().

This is a bit "wordy", but gets the job done.

vidishac2004 and others added 3 commits July 25, 2025 17:33
Co-authored-by: Pete LeVasseur <plevasseur@gmail.com>
Co-authored-by: Pete LeVasseur <plevasseur@gmail.com>
@vidishac2004
Copy link
Copy Markdown
Contributor

Hey @vidishac2004 -- nearing completion! I left a few comments and the build is failing.

This has now been resolved.

Co-authored-by: Pete LeVasseur <plevasseur@gmail.com>
@sophokles73 sophokles73 merged commit 0bceeb2 into eclipse-uprotocol:main Jul 25, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conversion functions from UMessage <=> iceoryx2 user header + payload

4 participants